#ifndef PILHA_HPP_
#define PILHA_HPP_

#include "container.hpp"
#include <vector>

template <class T>
class pilha : public container<T>
{
public:

	void
	push(const T);
	
	std::vector<T>
	list();
	
	unsigned int
	getSize();	

};


/**********************************
 * 
 *      Implementations
 * 
 * ********************************/


template <class T> void
pilha<T>::push(const T _info)
{
	noh<T>*
	newNoh = new noh<T>;
	
	newNoh->setInfo(_info);

	if (this->cursor == 0)
	{
		this->cursor = newNoh;
	}
	else
	{
		this->cursor->setPosterior(newNoh);
		newNoh->setAnterior(this->cursor);

		this->cursor = newNoh;
	}
}

template <class T> std::vector<T>
pilha<T>::list()
{

	std::vector<T>
	tmpVect;
	
	noh<T>*
	tmpCursor = this->cursor;
	
	while( tmpCursor )
	{
		tmpVect.insert( tmpVect.begin() , tmpCursor->getInfo() );
		
		tmpCursor = tmpCursor->getAnterior();
	}
	
	return tmpVect;
	
}

template <class T> unsigned int
pilha<T>::getSize()
{
	
	noh<T>*
	tmpCursor = this->cursor;
	
	unsigned int
	size = 0;
	
	while( tmpCursor )
	{
		size++;
		
		tmpCursor = tmpCursor->getAnterior();
	}
	
	return size;
}

#endif /*PILHA_HPP_*/
